package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type TResponse struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func Response(c *gin.Context, httpStatus int, code int, msg string, data gin.H) {
	c.JSON(
		httpStatus,
		gin.H{
			"code": code,
			"msg":  msg,
			"data": data,
		})
}

func Success(c *gin.Context, msg string, data gin.H) {
	Response(c, http.StatusOK, 200, msg, data)
}

func Fail(c *gin.Context, code int, msg string, data gin.H) {
	Response(c, http.StatusOK, code, msg, data)
}
